package com.ruoyi.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.service.IPSzxqjcjService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.domain.dao.PSzxqjcj;

import com.ruoyi.common.utils.poi.ExcelUtil;


@Api(tags = "业务——检查井管理")
@RestController
@RequestMapping("/admin/szxqjcj")
public class PSzxqjcjController extends BaseController {
    @Autowired
    private IPSzxqjcjService pSzxqjcjService;


    /**
     * 导出【请填写功能名称】列表
     */
    @PreAuthorize("@ss.hasPermi('controller:szxqjcj:export')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PSzxqjcj pSzxqjcj) {
        List<PSzxqjcj> list = pSzxqjcjService.selectPSzxqjcjList(pSzxqjcj);
        ExcelUtil<PSzxqjcj> util = new ExcelUtil<PSzxqjcj>(PSzxqjcj.class);
        util.exportExcel(response, list, "【请填写功能名称】数据");
    }

    /**
     * 获取【请填写功能名称】详细信息
     */
    @PreAuthorize("@ss.hasPermi('controller:szxqjcj:query')")
    @GetMapping(value = "/{gid}")
    public AjaxResult getInfo(@PathVariable("gid") Long gid) {
        return success(pSzxqjcjService.selectPSzxqjcjByGid(gid));
    }

    /**
     * 新增【请填写功能名称】
     */
    @PreAuthorize("@ss.hasPermi('controller:szxqjcj:add')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PSzxqjcj pSzxqjcj) {
        return toAjax(pSzxqjcjService.insertPSzxqjcj(pSzxqjcj));
    }

    /**
     * 修改【请填写功能名称】
     */
    @PreAuthorize("@ss.hasPermi('controller:szxqjcj:edit')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PSzxqjcj pSzxqjcj) {
        return toAjax(pSzxqjcjService.updatePSzxqjcj(pSzxqjcj));
    }

    /**
     * 删除【请填写功能名称】
     */
    @PreAuthorize("@ss.hasPermi('controller:szxqjcj:remove')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
    @DeleteMapping("/{gids}")
    public AjaxResult remove(@PathVariable Long[] gids) {

        return toAjax(pSzxqjcjService.deletePSzxqjcjByGids(gids));
    }

    @ApiOperation("按照管道号查询-检查井")
    @GetMapping(value = "/findByPipeNum")
    @Anonymous
    public AjaxResult findByPipeNum(@RequestParam("pipeNum") String pipeNum) {
        return success(pSzxqjcjService.findByPipeNum(pipeNum));
    }

}


